package com.k.demo.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.k.demo.entity.Food;

@Mapper
public interface FoodMapper {

	@Select("select * from food where is_delete=1")
	List<Food> selectAll();
	
//	@Select("select * from food where instr(food_name,#{food_name})>0 and is_delete=1")
	List<Food> selectByNameAndKind(Food food);
	
	@Select("select * from food where instr(food_name,#{food_name})>0 and is_delete=1")
	List<Food> selectByName(String food_name);
	
	@Select("select * from food where food_kind_id=#{food_kind_id} and is_delete=1")
	List<Food> selectByKind(int food_kind_id);
	
	@Select("select * from food where food_id=#{food_id} and is_delete=1")
	Food selectById(int food_id);
	
	int insert(Food food);
	
	int update(Food food);
	
	int deleteForEach(List<Integer> deletelist);
	
	
	@Update("update food set is_delete =0 where food_id=#{food_id} and is_delete=1")
	int delete(int food_id);
	
	//按一定书序获取所有的菜品,传入参数为一个排序条件
	List<Food> getFoodByOrder(String orderBy);
	
	//根据传入的菜品对象动态查询
	List<Food> getFoodByFood(@Param("food")Food food,@Param("lowestPrice")Double lowestPrice,@Param("highestPrice")Double highestPrice,@Param("orderBy")String orderBy);
	
}
